Skip to content

Basic villager trades#1819

Open
Ragnok123 wants to merge 4 commits intoCloudburstMC:masterfrom
Ragnok123:master
Open

Basic villager trades#1819
Ragnok123 wants to merge 4 commits intoCloudburstMC:masterfrom
Ragnok123:master

Conversation

@Ragnok123
Copy link
Copy Markdown

@Ragnok123 Ragnok123 commented Apr 2, 2021

This pull request should add basic villager trade inventory with custom api.

Screenshot_2021-04-06-01-02-23-334_com mojang minecraftpe

Comment thread src/main/java/cn/nukkit/entity/passive/EntityVillager.java Outdated
import cn.nukkit.nbt.tag.ListTag;

public class EntityVillager extends EntityCreature implements EntityNPC, EntityAgeable {
public class EntityVillager extends EntityCreature implements InventoryHolder, EntityNPC, EntityAgeable {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about implementing InventoryHolder here, since it has no physical inventory

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or does it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Villager trading is inventory and since villager contains trade recipes, i find them as inventory holders.

Comment thread src/main/java/cn/nukkit/entity/passive/EntityVillager.java Outdated
Fix nbt
Handle trade inventory transaction
}

@Override
public boolean onInteract(Player player, Item item) {
Copy link
Copy Markdown
Contributor

@lt-name lt-name May 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Google Translate)
I think we also need to rewrite the onInteract(Player player, Item item, Vector3 clickedPos) method
like this:

    @Override
    public boolean onInteract(Player player, Item item, Vector3 clickedPos) {
        if (super.onInteract(player, item, clickedPos)) {
            return true;
        }
        return this.onInteract(player, item);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants